/**
 * 
 */
package com.ms.service.module.gamelog.async;

import java.io.File;
import java.io.FilenameFilter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 列出 log 佔存檔清單時用的檔名過濾器
 * 
 * @author TW15010
 */
public class LogFileNameFilter implements FilenameFilter {
	/**
	 * 比對檔案名稱用的正規表示式
	 * <p>
	 * 檔名範例: archive-2016-06-13-16-41-1-server01.txt
	 */
	private static Pattern pattern = Pattern
			.compile("^archive-[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2}-[0-9]{2}-[0-9]+-"
					+ System.getProperty("logName") + "\\.txt$");

	@Override
	public boolean accept(File dir, String name) {
		Matcher matcher = pattern.matcher(name);
		return matcher.matches();
	}
}
